#include <iostream>
#include<string>
using namespace std;


int main()
{
	

	string A="abcge" ;
	string B="abk";
	int i = 0;
	cin >> A;
	cin >> B;
	while (i < B.length())
	{
		if (A.find(B[i],0)!=-1)
		{
			cout << "Y";

		}
		else
		{
			cout << "N";
		}
		
		i++;
	}
	
	
	
}


